// 2006-10-12  Paolo Carlini  <pcarlini@suse.de>

// Copyright (C) 2006, 2007 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING.  If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.

// 21.3.7.9 inserters and extractors

#include <ostream>
#include <sstream>
#include <boost/test/unit_test.hpp>
#include <xpcom/string.hpp>

// GCC >= 4.3 or others
#ifdef __GNUC__
#if __GNUC__ > 4 || (__GNUC__ == 4 && defined(__GNUC_MINOR__) && __GNUC_MINOR__ >= 3)
#define __TEST_IO_12__
#endif
#else // __GNUC__
#define __TEST_IO_12__
#endif // __GNUC__

#ifdef __TEST_IO_12__

// libstdc++/28277
BOOST_AUTO_TEST_CASE(test_io_12)
{
  using namespace xpcom;

  std::ostringstream oss_01;
  const string str_01(50, 'a');

  oss_01.width(20000000);
  const std::streamsize width = oss_01.width();

  oss_01 << str_01;

  BOOST_CHECK( oss_01.good() );
  BOOST_CHECK( oss_01.str().size() == string::size_type(width) );
}

#endif
